package codeComposition;

import java.util.*;

public class ListAssighElement extends AssignElement {
	ArrayList<ReferenceElement> varList = new ArrayList<ReferenceElement>();
	String to;
	
	public ListAssighElement(int tabNum){
		super(tabNum);
	}
	public ListAssighElement(String[] l, String to){
		for(String s:l){
			varList.add(new ReferenceElement(s));
		}
		this.to = to;
		tabStr = "";
	}
	
	public ListAssighElement(ArrayList<String> l, String to){
		for(String s:l){
			varList.add(new ReferenceElement(s));
		}
		this.to = to;
		tabStr = "";
	}
	
	public ListAssighElement(String[] l, String to, int tabNum){
		super(tabNum);
		for(String s:l){
			varList.add(new ReferenceElement(s));
		}
		this.to = to;
	}
	public ListAssighElement(ArrayList<String> l, String to, int tabNum){
		super(tabNum);
		for(String s:l){
			varList.add(new ReferenceElement(s));
		}
		this.to = to;
	}
	
	public void addVar(ReferenceElement v){
		varList.add(v);
	}
	
	public String toString(){
		String str = tabStr + to.toString() + " = " + "[";
		for(ReferenceElement s:varList){
			str = str + "\n\t" + tabStr +  s.toString() + ",";
		}
		return str + "]\n";
	}
	
//	public void test(){
//		String[] sl = {"var1", "var2", "var3"};
//		VarElement to = new VarElement("to");
//		ListAssighElement lae = new ListAssighElement(sl, to);
//		System.out.println(lae.toString());
//	}
	public static void main(String[] argvs){
		String[] sl = {"var1", "var2", "var3"};
		String to = new String("to");
		ListAssighElement lae = new ListAssighElement(sl, to);
		ListAssighElement lae2 = new ListAssighElement(sl, to, 2);
		System.out.println(lae.toString() + lae2.toString());
	}
}
